/**
 * Created by giozola on 2018/5/4.
 */
/**
 * ajax 調用，通用方法
 * @param url
 * @param data
 * @param callback
 */
var ajaxUrl = function(url,data,successallback){
    $.ajax({
        url: url,
        type: 'POST',
        data: data,
        dataType: "json",
        success: function(res){
            if (isString(res)){
                res = JSON.parse(res);
            }
            successallback(res);
        },
        error:function(XMLHttpRequest, textStatus, errorThrown){
            // 状态码
            console.log(XMLHttpRequest.status);
            // 状态
            console.log(XMLHttpRequest.readyState);
            // 错误信息
            console.log(textStatus);
            layer.alert("错误");
            layer.closeAll('loading');
        }
    });
}

var isObj = function(obj){
    var r = false;
    if(typeof obj == "object"){
        r = true;
    }
    return r;
}

var isString = function(obj){
    var r = false;
    if(typeof obj == "string"){
        r = true;
    }
    return r;
}